/* 模拟数据 */
const Mock = require('mockjs')
const Random = Mock.Random

/* 树节点（系-专业-班级） */
Mock.mock('/tree',(req, res) => {
    const treeList = []
    // 生成系别
    for (let i = 0; i < Random.integer(1, 10); i++) {
        // 生成班级
        const classList = []
        for (let j = 0; j < Random.integer(1, 5); j++) {
            const classes = {
                label: Random.csentence(5, 10),
                labelType: '3',
                labelId: Random.integer(10000, 50000)
            }
            classList.push(classes)
        }
        // 生成专业
        const majorList = []
        for (let k = 0; k < Random.integer(1, 5); k++) {
            const major = {
                label: Random.csentence(5, 10),
                children: classList,
                labelType: '2',
                labelId: Random.integer(1000, 5000)
            }
            majorList.push(major)
        }

        const depart = {
            label: Random.csentence(5, 10),
            children: majorList,
            labelType: '1',
            labelId: Random.integer(100, 500)
        }
        treeList.push(depart)
    }
    return {
        data: treeList
    }
})

/* 毕业生数据 */
Mock.mock('/stuData',(req, res) => {
    const stuData = []
    // 生成系别
    for (let i = 0; i < Random.integer(1, 10); i++) {
        const stu = {
            sNo: Random.integer(1708030000, 1708039999),        //学号
            sName: Random.name(),               //姓名
            instructor: Random.name(),          //导师名称
            phone: Random.integer(1104234423, 1123432432),              //联系电话
            assistant: Random.name(),           //辅导员
            internshipUnit: Random.csentence(5, 10),    //实习单位
            internshipAddress: Random.csentence(5, 10),    //实习地址
            internshipPosition: Random.csentence(5, 10)    //实习岗位
        }
        stuData.push(stu)
    }
    return {
        code: '200',
        data: stuData
    }
})


/* 毕业论文数据 */
Mock.mock('/thesisData',(req, res) => {
    const thesisData = []
    const keywordArr = []
    // 生成关键词
    for (let j = 0; j < Random.integer(1, 3); j++) {
        keywordArr.push(Random.csentence(4, 5))
    }
    // 生成论文数据
    for (let i = 0; i < Random.integer(1, 10); i++) {
        const thesis = {
            sNo: Random.integer(1708030000, 1708039999),        //学号
            sName: Random.name(),               //姓名
            title: Random.csentence(5, 10),          //题目
            keywords: keywordArr,              //关键词
            thesisFile: Random.csentence(5, 10),    //论文文件
            enclosure: Random.csentence(5, 10)    //附件
        }
        thesisData.push(thesis)
    }
    return {
        code: '200',
        data: thesisData
    }
})

Mock.mock('/batchDelThesis', (req, res) => {
    const code = '200'
    return {
        code: code
    }
})

Mock.mock('/delThesis', (req, res) => {
    const code = '200'
    const result = '删除成功'
    return {
        code: code,
        msg: result
    }
})

Mock.mock('/batchDelStu', (req, res) => {
    const code = '200'
    const result = '批量删除失败'
    return {
        code: code,
        msg: result
    }
})

Mock.mock('/delStu', (req, res) => {
    const code = '200'
    const result = '删除失败'
    return {
        code: code,
        msg: result
    }
})

Mock.mock('/downloadThesis', (req, res) => {
    const code = '200'
    return {
        code: code
    }
})


Mock.mock('/downloadEnclu', (req, res) => {
    const code = '200'
    return {
        code: code
    }
})




Mock.mock('/api/query', (req, res) => {
    const code = '0000'
    const result = '修改成功'
    return {
        code: code,
        result: result
    }
})


Mock.mock('/graInfo/getInstructor', (req, res) => {
    const instruData = []
    // 生成论文数据
    for (let i = 0; i < Random.integer(1, 10); i++) {
        const instru = {
            iNo: Random.integer(1708030000, 1708039999),        //指导老师id
            iName: Random.name(),               //指导老师姓名
        }
        instruData.push(instru)
    }
    return {
        data: instruData
    }
})



Mock.mock('/graInfo/addGraInfo', (req, res) => {
    const code = '0000'
    return {
        code: code
    }
})

Mock.mock('/graInfo/editGraInfoById', (req, res) => {
    const code = '0000'
    return {
        code: code
    }
})


Mock.mock('/graThesis/getSName', (req, res) => {
    const code = '0000'
    const sname = Random.name()
    return {
        code: code,
        data: sname
    }
})



